<?php

namespace App\Http\Requests;

use App\Constants\CodeResponse;
use App\Exceptions\ValidateException;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;

class BaseRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * 校验参数异常
     * @param  Validator  $validator
     * @throws ValidateException
     */
    public function failedValidation(Validator $validator)
    {
        throw new ValidateException(CodeResponse::PARAM_ILLEGAL,$validator->errors()->first());
    }
}